Oa.controller('staffInfoCtrl',function($scope,$http){
		$scope.showModal = false;
		$scope.delStaff = function(id) {
			$scope.showModal = !$scope.showModal;
			$scope.delStaffId = id;
		};
		$scope.sureDelStaff = function() {
			$http.post(delUserById_url, {
					userId: $scope.delStaffId
				})
				.success(function(res) {
					if (res.code==200) {
						$scope.getRecord();
					}
					Notify(res.msg,"top-right");
				}).error(function() {
					Notify("客户端错误","top-right");
			});
			$scope.showModal = !$scope.showModal;
		}

/**********   添加员工信息start***************/
  $scope.newProvider = {};
  $scope.showAModel = false;
  $scope.addProviderBtn = function() {
  	console.log(1)
    $scope.showAModel = !$scope.showAModel;
  }
  $scope.addProvider = function() {
  $http.post(addProviderURL,$scope.newProvider)
  .success(function(res){
   if (!res.serviceResult) {
//    alertMes(res.serviceResult,res.resultInfo);
    }else {
//    $scope.getRecord();
//      $scope.showAModel = !$scope.showAModel;
    }
  }).error(function(){
    alertMes('noHttp',null);
  });
  }






	$scope.totalPage = 1;//全部页数
	$scope.currentPage = 1;//当前页码
	$scope.pageArr;// 页码数组
	$scope.size = 15;
	// 生成页码数组
	$scope.getPage = function(num){
		$scope.pageArr = new Array();
		for(var i=0;i<num;i++){
			$scope.pageArr[i] = i+1;
		}
	}
	//获取   第n页的订单记录
	$scope.getStaff = function(num){
		if(num>=1 && num<=$scope.totalPage){
				$http.get(getAllUser_url,
					{
						params:{
							page:num,
							size:$scope.size
						}
					})
				.success(function(res){
					if (res.code==200) {
						$scope.staff = res.data.list;
						$scope.totalPage = res.data.countPage;
					  $scope.currentPage = num;
					  $scope.getPage($scope.totalPage);
						$scope.recordsnum = res.data.recordsNum;
					}else {
						Notify(res.msg,"top-right");
					}
				}).error(function(){
					Notify('客户端错误',"top-right");
			});
		}
	}
	$scope.getRecord = function(){
		$scope.getStaff($scope.currentPage);
	}
	$scope.getRecord();




	//通过名字查询 员工
	$scope.findStaffByName = function(id){
		if(id!=null && id!='' && id!=' '){
			$http.get(findUserByName_url,
				{
					params:{name:id}
				})
				.success(function(res){
					if (res.code==200) {
						$scope.staff = res.data;
						$scope.totalPage = 1;
						$scope.currentPage = 1;
						$scope.recordsnum = res.data.length;
						$scope.getPage(1);
					}else {
						Notify(res.msg,"top-right");
					}
				}).error(function(){
					Notify('客户端错误',"top-right");
			});
		}
	}
	$scope.keyupId = function(){
		if(window.event.keyCode == 13){
			$scope.findStaffByName($scope.checkname);
		}
	}




});
